﻿<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                    xmlns:Controls="clr-namespace:SharpFellows.Toolkit.Controls">

    <Geometry x:Key="DownArrowGeometry">M 0 0 L 3.5 3 L 7 0 Z</Geometry>
    <Geometry x:Key="UpArrowGeometry">M 0 3 L 3.5 0 L 7 3 Z</Geometry>

    <Style TargetType="{x:Type Controls:DomainUpDown}">
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type Controls:DomainUpDown}">
                    <Border 
                            FocusManager.IsFocusScope="True"
                            Background="{TemplateBinding Background}"
                            BorderBrush="{TemplateBinding BorderBrush}"
                            BorderThickness="{TemplateBinding BorderThickness}">
                        <Grid HorizontalAlignment="Stretch">
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition />
                                <ColumnDefinition Width="Auto" />
                            </Grid.ColumnDefinitions>
                            <TextBlock Grid.Column="0"
                                       Name="PART_TextBox"
                                       VerticalAlignment="Center"
                                       Margin="5,0,0,0"
                                       Text="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Controls:DomainUpDown}}, Path=Value}" />
                            <Grid Grid.Column="1">
                                <Grid.RowDefinitions>
                                    <RowDefinition />
                                    <RowDefinition />
                                </Grid.RowDefinitions>
                                <RepeatButton Grid.Row="0"
                                              Name="PART_UpButton">
                                    <Path HorizontalAlignment="Center"
                                          VerticalAlignment="Center"
                                          Margin="2,0,2,0"
                                          Fill="{TemplateBinding Foreground}"
                                          Data="{StaticResource UpArrowGeometry}" />
                                </RepeatButton>
                                <RepeatButton Grid.Row="1"
                                              Name="PART_DownButton">
                                    <Path Margin="2,0,2,0"
                                          HorizontalAlignment="Center"
                                          VerticalAlignment="Center"
                                          Fill="{TemplateBinding Foreground}"
                                          Data="{StaticResource DownArrowGeometry}" />
                                </RepeatButton>
                            </Grid>
                        </Grid>
                    </Border>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>
</ResourceDictionary>